package com.hotel.suqiang.dingdonegurad.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by suqiang on 17/6/1.
 */

public class SharedPreferencesUtis {

    private static SharedPreferences sp = null;

    public static  void saveBoolean(Context context, String key, boolean value){
        if (sp == null){
            sp = context.getSharedPreferences("settings", Context.MODE_PRIVATE);
        }
        sp.edit().putBoolean(key, value).commit();
    }

    public  static  boolean getBoolean(Context context, String key, boolean defaultValue){
        if (sp == null){
            sp = context.getSharedPreferences("settings", Context.MODE_PRIVATE);
        }

        return sp.getBoolean(key, defaultValue);
    }


    public static  void saveString(Context context, String key, String value){
        if (sp == null){
            sp = context.getSharedPreferences("settings", Context.MODE_PRIVATE);
        }
        sp.edit().putString(key, value).commit();
    }

    public  static  String getString(Context context, String key, String defaultValue){
        if (sp == null){
            sp = context.getSharedPreferences("settings", Context.MODE_PRIVATE);
        }

        return sp.getString(key, defaultValue);
    }



}
